import * as echarts from 'echarts/core'
// 按需引入需要的图表类型
import {
    LineChart,
    BarChart,
    PieChart
} from 'echarts/charts'
// 引入必要组件
import {
    TitleComponent,
    TooltipComponent,
    GridComponent,
    DatasetComponent,
    TransformComponent,
    DataZoomComponent,
    LegendComponent
} from 'echarts/components'
// 选择 Canvas 渲染器
import { CanvasRenderer, SVGRenderer } from 'echarts/renderers'
// 系列类型的定义后缀都为 SeriesOption
import type {
    BarSeriesOption,
    LineSeriesOption,
    PieSeriesOption
} from 'echarts/charts';
// 组件类型的定义后缀都为 ComponentOption
import type {
    TitleComponentOption,
    TooltipComponentOption,
    GridComponentOption,
    DatasetComponentOption, DataZoomComponentOption
} from 'echarts/components';
import type { ComposeOption, } from 'echarts/core';

declare global {
    export type ECOption = ComposeOption<
        | BarSeriesOption
        | LineSeriesOption
        | PieSeriesOption
        | TitleComponentOption
        | TooltipComponentOption
        | GridComponentOption
        | DatasetComponentOption | DataZoomComponentOption
    >;
}

// 注册必须的组件
echarts.use([
    LineChart,
    BarChart,
    PieChart,
    TitleComponent,
    TooltipComponent,
    GridComponent,
    DatasetComponent,
    TransformComponent,
    DataZoomComponent,
    CanvasRenderer,
    SVGRenderer,
    LegendComponent
])

export default echarts